Introduction

This is a demonstration regarding semantic priming. For problems or suggestions, please contact me michael.espero@cgu.edu.

Setup & Data Import

set.seed(789)

# This build only requires that you have the "easypackages" library pre-installed. If it throws an error, try installing "easypackages" with install.packages()
require(easypackages)
packages(
  "tidyverse", "broom", "skimr", "plotly", "apaTables", "GGally",
  "caret", "psych", "haven", "car", "ggthemes"
)

# We can make a pointer called "dat" to data we stored on Github.
dat <- "https://raw.githubusercontent.com/michaelespero/data-projects/master/dat_ex_1_semantic_priming.csv"

dat <- read_csv(dat) # Read in the data from the specified url.


# dat <- read_sav("eprime/exp_1_spss_data.sav")
# We can make a pointer called "dat" to data we stored on Github.
# Here, we filter the observations so only correct responses will be in dat.
dat <- dat %>%
  filter(TargetAcc == 1)

# Let's make sure we have only the correct responses.
# dat %>%
#  filter(TargetAcc == 1) %>%
#  count()

# We want Target Accuracy and Trial Type to work as factors
dat$TargetAcc <- as.factor(dat$TargetAcc)
dat$TrialType <- as.factor((dat$TrialType))

# Let's make it clear that our first column contains the number of each trial.
#names(dat)[names(dat) == "X1"] <- "TrialNum"

class(dat) # Is it a data frame?
[1] "tbl_df"     "tbl"        "data.frame"
dim(dat) # How many dimensions does our data have in terms of rows and columns?
[1] 152   4
skim(dat) # Now let's call up descriptive statistics and histograms.
Skim summary statistics
 n obs: 152 
 n variables: 4 

Variable type: factor 
   variable missing complete   n n_unique                       top_counts
1 TargetAcc       0      152 152        1                    1: 152, NA: 0
2 TrialType       0      152 152        3 Non: 76, Wor: 38, Wor: 38, NA: 0
  ordered
1   FALSE
2   FALSE

Variable type: integer 
  variable missing complete   n   mean     sd min    p25 median    p75
1 TargetRT       0      152 152 599.15 149.99 385 504.25  554   652   
2       X1       0      152 152  76.5   44.02   1  38.75   76.5 114.25
   max     hist
1 1237 ▃▇▅▂▁▁▁▁
2  152 ▇▇▇▇▇▇▇▇
# Is the dependent variable normally distributed?
skew(dat$TargetRT)
[1] 1.619998
kurtosi(dat$TargetRT)
[1] 3.128417

Show

What do you notice?:

glimpse(dat)
Observations: 152
Variables: 4
$ X1        <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1...
$ TargetAcc <fctr> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...
$ TargetRT  <int> 954, 532, 688, 1237, 483, 727, 563, 1013, 669, 539, ...
$ TrialType <fctr> Nonword, WordUnrelated, Nonword, WordRelated, Nonwo...
# We can use this nifty function to make a matrix illustrating bivariate relationships in the data.
ggpairs(dat)

# 3D plots may be helpful in further exploration of how the data hangs together.

p0 <- plot_ly(data = dat, z = ~TargetRT, x = ~TrialType, y = ~TargetAcc, opacity = 0.6) %>% add_markers(color = ~TargetAcc)
p0
# Let's make a violin plot: c1
c1 <- ggplot(dat, aes(x = TargetAcc, y = as.numeric(TargetRT), fill = TrialType)) +
  geom_violin() + theme_tufte() +
  labs(
    fill = "Kind of Trial",
    title = "K.R.'s Reaction Time by Accuracy",
    y = "Reaction Time in Milliseconds", x = "Accuracy", subtitle = "Distribution of Responses by K. R.",
    caption = "Claremont, Spring 2018"
  ) +
  scale_x_discrete(labels = c("Right")) + coord_flip()

# Let's make a boxplot: c2
c2 <- ggplot(dat, aes(x = TargetAcc, y = as.numeric(TargetRT), col = TrialType)) +
  geom_boxplot() + theme_tufte() +
  labs(
    col = "Kind of Trial",
    title = "K.R.'s Reaction Time by Accuracy",
    y = "Reaction Time in Milliseconds", x = "Accuracy", subtitle = "Distribution of Responses by K. R.",
    caption = "Claremont, Spring 2018"
  ) +
  scale_x_discrete(labels = c("Right")) + coord_flip()

# Display plots c1 and c2
c1

c2

Analyses

How might we test the data?:

# Assumption Check: is the variance equal?
leveneTest(dat$TargetRT, group = dat$TrialType, center = mean)
Levene's Test for Homogeneity of Variance (center = mean)
       Df F value  Pr(>F)  
group   2  2.9262 0.05669 .
      149                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Specify the linear model
react_mod <- lm(TargetRT ~ TrialType, dat)

# Let's get some ANOVA output
kable(sjstats::anova_stats(react_mod), booktabs = T)
term df sumsq meansq statistic p.value etasq partial.etasq omegasq cohens.f power
TrialType 2 2526.48 1263.24 0.055 0.946 0.001 0.001 -0.013 0.027 0.058
Residuals 149 3394537.04 22782.13 NA NA NA NA NA NA NA
# Let's have another look with robust standard errors
Anova(
  react_mod, Type = "II",
  white.adjust = TRUE
)
Analysis of Deviance Table (Type II tests)

Response: TargetRT
           Df      F Pr(>F)
TrialType   2 0.0493 0.9519
Residuals 149              
# One more ANOVA, this time using the Welch's correction for unequal variance.
oneway.test(
  TargetRT ~ TrialType,
  data = dat,
  var.equal = FALSE
)

    One-way analysis of means (not assuming equal variances)

data:  TargetRT and TrialType
F = 0.049981, num df = 2.000, denom df = 72.008, p-value = 0.9513
# How do the means line up by trial type?
TukeyHSD(aov(react_mod))
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = react_mod)

$TrialType
                               diff       lwr      upr     p adj
WordRelated-Nonword        9.802632 -61.19059 80.79585 0.9428256
WordUnrelated-Nonword      5.065789 -65.92743 76.05901 0.9843930
WordUnrelated-WordRelated -4.736842 -86.71275 77.23906 0.9897373
plot(TukeyHSD(aov(TargetRT ~ TrialType, dat)))

Interpretation

It appears that regardless of trial type (nonword, unrelated word, related word), K. R. remained consistent with regards to speed of response and accuracy. For K. R., there appears to be no semantic priming effect in the sample at hand.